IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[cms_sp_ContentSelectOne]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[cms_sp_ContentSelectOne]
GO

create procedure [dbo].[cms_sp_ContentSelectOne]
(
	@Id int
)
as

select 
	c.ContentId as Id,
	c.PublicContentId,
	c.SiteId,
	c.SiteGroupId,
	c.SystemLanguageId,
	c.ContentTypeId,
	c.ContentTitle,
	c.ContentSummary,
	c.ContentBody,
	c.ContentCode,
	c.CreatedBy,
	c.DateCreated,
	c.LastUpdatedBy,
	c.DateLastUpdated,
	er.IsDeleted,
	er.IsLatestCompletedRevision,
	er.IsLatestRevision,
	er.IsPublished,
	er.PublishEndDate,
	er.PublishStartDate,
	er.WorkflowId
from Contents c
left join EntityRevisions er on er.EntityId = c.ContentId and er.EntityTypeParameter='Content'+CAST(c.ContentTypeId as nvarchar(50))
where ContentId = @Id


GO
